#include "string.h"
namespace refrain
{
	void test_string01()
	{
		string s1("hello world");

		std::cout << s1.c_str() << std::endl;

		for (size_t i = 0; i < s1.size(); i++)
		{
			std::cout << s1[i] << std::endl;
		}
		for (auto ch : s1)
		{
			std::cout << ch;
		}
		std::cout << std::endl;
		/*s1.push_back('x');
		for (auto ch : s1)
		{
			std::cout << ch;
		}
		std::cout << std::endl;*/

		s1.append("xxxxxx");
		for (auto ch : s1)
		{
			std::cout << ch;
		}
	}
	void test_string02()
	{
		string s1("hello world");
		s1.push_back('\0');
		s1.append("xxxxxxxx");
		for (auto ch : s1)
		{
			std::cout << ch;
		}
		std::cout << std::endl;

		std::cout << s1.c_str() << std::endl;
	}
	void test_string03()
	{
		string s1("hello world");
		s1.insert(6, 'x');

		std::cout << s1.c_str() << std::endl;

		string s2("hello world");

		s2.erase(2, 3);
		std::cout << s2.c_str() << std::endl;

		string s3("hello world");
		s3.insert(2, "xxxxxxx");
		std::cout << s3.c_str() << std::endl;
	}
	void test_string04()
	{
		string s1("hello world");

		size_t pos = s1.find('w');
		s1[pos] = 'x';
		std::cout << s1.c_str() << std::endl;

		string s2("hello world");
		string s3 = s2.substr(3);

		std::cout << s3.c_str() << std::endl;

		string s4("hello world");
		string s5 = s2.substr(3, 4);
		std::cout << s5.c_str() << std::endl;


	}
	void test_string05()
	{
		string s1("hello world");
		string s2 = s1 + "xxxx";
		std::cout << s1.c_str() << std::endl;
		std::cout << s2.c_str() << std::endl;
		string s3("hello world");

		s3 += "xxxxx";
		std::cout << s3.c_str() << std::endl;


	}
	void test_string06()
	{
		string s1("hello world");
		std::cout << s1 << std::endl;

		string s2, s3; std::cin >> s2 >> s3;
		std::cout << s2 << std::endl;
		std::cout << s3 << std::endl;

	}
	void test_string07()
	{
		string s1("hello world");
		std::cout << s1 << std::endl;
		string s2(s1);
		std::cout << s2 << std::endl;

		string s3("xxxxxxxxxxxxxxxxxxxx");
		s1 = s3;
		std::cout << s1 << std::endl;
		std::cout << s3 << std::endl;

	}
	void test_string08()
	{
		string s1("hello ");
		string s2 = s1;
		std::cout << s2 << std::endl;

	}

}
int main()
{
	refrain::test_string08();
	return 0;
}
